// gui/GuiTickBox.h

#ifndef _GUI_GuiTickBox_H_
#define _Gui_GuiTickBox_H_

#ifndef _CORE_std_H_
#include <core/std.h>
#endif

#ifndef _GUI_GuiHotSpotRect_H_
#include "GuiHotSpotRect.h"
#endif

#ifndef _GUI_GuiSelectable_H_
#include "GuiSelectable.h"
#endif

#ifndef _GUI_GuiSprite_H_
#include "GuiSprite.h"
#endif

namespace GFX
{
	class Texture;
};

namespace GUI
{

class GuiTickBox : public GuiSelectable
{
public:

	GuiTickBox();

	virtual TypeId			GetTypeId() const {
		return s_TypeId;
	}
	static TypeId			GetStaticTypeId() {
		return s_TypeId;
	}

	void					SetupGuiTickBox(GFX::Texture * pBoxTexture,
											GFX::Texture * pTickTexture);

	// Accessors
	virtual void			SetSelectable(bool bSelectable) {
		GuiSelectable::SetSelectable(bSelectable);
		m_bVisualDirty = true;
	}
	virtual void			SetHighlightable(bool bHighlightable) {
		GuiSelectable::SetHighlightable(bHighlightable);
	}

	bool					IsTicked() const {
		return m_bTicked;
	}
	void					SetTicked(bool bTicked) {
		m_bTicked = bTicked;
	}

	// APIs
	virtual bool			OnSelect();

	virtual bool			OnHighlight(bool bHighlighted);
	virtual void			Update(CORE::Time & TimeDelta);
	virtual void			Render(IRenderingEngine * pRenderer);


private:

	static TypeId			s_TypeId;

	bool					m_bVisualDirty;
	GuiHotSpotRect			m_HotSpotRect;
	bool					m_bTicked;
	GuiSprite				m_BoxSprite;
	GuiSprite				m_TickSprite;
};

// inline functions
inline GuiTickBox::GuiTickBox()
	: m_bVisualDirty(true)
	, m_bTicked(false)
{
}

inline bool GuiTickBox::OnSelect()
{
	bool bSuccess = GuiSelectable::OnSelect();

	if (bSuccess)
		SetTicked(!m_bTicked);

	return bSuccess;
}

inline bool GuiTickBox::OnHighlight(bool bHighlighted)
{
	bool bSuccess = GuiSelectable::OnHighlight(bHighlighted);
	m_bVisualDirty = true;

	return bSuccess;
}

}; // namespace GUI


#endif // _Gui_GuiTickBox_H_